﻿@using MvcAtletIS.Helpers;
@model IEnumerable<MvcAtletIS.Models.Statistics>

@{
    ViewBag.Title = "Editor štatistiky";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Editor štatistiky</h2>

<p>
    Vyberte rok a pretekára, pre ktorého chcete zobraziť a editovať štatistiku.
</p>

@using (Html.BeginForm())
{   
    
    <div class="filter-frame">
        
        <div class="filter-item">
            <div class="editor-label">
                Rok
            </div>
            <div class="editor-field">
                @Html.DropDownList("Year", null, "Vyberte rok", new { onchange = "this.form.submit();" })
            </div>
        </div>

        <div class="filter-item">
            <div class="editor-label">
                Klub
            </div>
            <div class="editor-field">
                @Html.DropDownList("ClubId", null, "Vyberte klub", new { onchange = "this.form.submit();" })
            </div>
        </div>

        <div class="filter-item">
            <div class="editor-label">
                Pretekár
            </div>
            <div class="editor-field">
                @Html.DropDownList("CompetitorId", null, "Vyberte pretekára", new { onchange = "this.form.submit();" })
            </div>
        </div>

    </div>
}

@if (Model.Count() > 0)
{
    <table width="100%">
        <tr>
            <th width="200px">
                Pretekár
            </th>
            <th width="180px">
                Disciplína
            </th>
            <th width="200px">
                Preteky
            </th>
            <th width="80px">
                Dátum
            </th>
            <th width="80px">
                Výkon
            </th>
            <th width="50px">
                Halový
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Competitors.FullName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Disciplines.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.StatisticsCompetitions.City)
                </td>
                <td align="right">
                    @Html.DisplayFor(modelItem => item.StatisticsCompetitions.Date)
                </td>
                <td align="center">
                    @Html.DisplayFor(modelItem => item.sResult)
                </td>
                <td align="center">
                    @Html.DisplayFor(modelItem => item.Indoor)
                </td>
                <td>
                    @Html.ImageActionLink(Url.Content("~/Content/icons/preview.gif"), "", "Details", new { id = item.ID }, new { title = "Zobraziť", border = 0, hspace = 2 }) | 
                    @Html.ImageActionLink(Url.Content("~/Content/icons/edit.gif"), "", "Edit", new { id = item.ID }, new { title = "Editovať", border = 0, hspace = 2 })
                </td>
            </tr>
        }

    </table>
}

<p>
    Počet záznamov: @Model.Count() | 
    @Html.ActionLink("Pridať nový záznam", "Create", new { Year = @ViewBag.Year.SelectedValue, ClubId = @ViewBag.ClubId.SelectedValue, CompetitorId = @ViewBag.CompetitorId.SelectedValue })
</p>

